<?php

namespace App\Jobs;

use App\Service\DunImageService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class CheckImage implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $checkData;
    protected $url;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($checkData)
    {
        $this->checkData = $checkData;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Log::info("推送检查图片", [
            'data' => $this->checkData
        ]);

        $imageService = DunImageService::getInstance();
        $imageService->setConfig(
            \config('app.dun_image_secret_id'),
            \config('app.dun_image_secret_key'),
            \config('app.dun_image_business_id')
        );
        $imageService->main($this->checkData);
    }
}
